import { observable,action } from 'mobx';
import {DeviceEventEmitter} from 'react-native';
import axios from "axios";
import '../netRule';


class MottoStore{
    @observable IsLoaded = false;
    @observable MottoData = {};

    @action
    async GetSingleMotto(){
        this.IsLoaded = false;
        try{
            const res = await axios.post('api/account',{name:'worker'});
            this.IsLoaded = true;
            this.MottoData = res.motto;
            DeviceEventEmitter.emit('loadMottoComplete');
            console.log(res);
        }catch(error){
            console.log(error);
        }
        // axios.post('api/account',{name:'worker'})
        // .then(res =>{
        //     this.IsLoaded = true;
        //     this.MottoData = res.motto;
        //     DeviceEventEmitter.emit('loadMottoComplete');
        //     console.log(res);
        // }).catch(error =>{
        //     console.log(error);
        // })
    }
}

const mottoStore = new MottoStore();
export {mottoStore};